package com.maben.exception;

import cn.dev33.satoken.exception.NotLoginException;
import com.maben.util.MyResponseUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 统一处理token失效,跳转到首页
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    // 处理未登录异常
    @ExceptionHandler(NotLoginException.class)
    public void handleNotLoginException(NotLoginException e, HttpServletRequest request, HttpServletResponse response) throws IOException {
        MyResponseUtil.handleNotLoginException(request,response);
    }
}